package com.yuchao.redis.properties;

import org.springframework.boot.context.properties.ConfigurationProperties;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;


@ConfigurationProperties(prefix = "my.redis")
public class MyRedisProperties {

	/**
	 * Redis服务器IP
	 */
    private String host = "192.168.207.48";

	/**
	 * Redis的端口号
	 */
		private int port = 6379;

	/**
	 * 访问密码
	 */
	private String auth = "group@123";

	/**
	 * 设置默认超时时间
	 */
	private Integer timeout = 3000;

	/**
     * 初始化Redis连接池
     */
    public JedisPool getJedisPool(){
    	JedisPoolConfig config = new JedisPoolConfig();
		//省略具体设置
        JedisPool myJedisPool = new JedisPool(config, host, port, timeout, auth);
        
        return myJedisPool;
    }

	public String getHost() {
		return host;
	}

	public void setHost(String host) {
		this.host = host;
	}

	public int getPort() {
		return port;
	}

	public void setPort(int port) {
		this.port = port;
	}

	public String getAuth() {
		return auth;
	}

	public void setAuth(String auth) {
		this.auth = auth;
	}

	public Integer getTimeout() {
		return timeout;
	}

	public void setTimeout(Integer timeout) {
		this.timeout = timeout;
	}
}
